package es.uji.viselab.robot;

import es.uji.viselab.kinematics.Kparameter;

public class RobotDatabase {

	public static String getFileNameRobot3D(RobotCatalog model) {
		switch (model) {
		case ABBIRB140:
			return "./resources/ABB_IRB_140.obj";
		case VABBIRB140:
			return getFileNameRobot3D(RobotCatalog.ABBIRB140);
		}
		return null;
	}

	public static int getNumberJoints(RobotCatalog model) {
		switch (model) {
		case ABBIRB140:
			return 6;
		case VABBIRB140:
			return getNumberJoints(RobotCatalog.ABBIRB140);
		case FANUCARC120:
			return 6;
		case VFANUCARC120:
			return getNumberJoints(RobotCatalog.FANUCARC120);
		default:
			break;
		}
		return 0;
	}

	public static Kparameter[] getDHParameters(RobotCatalog model) {
		Kparameter[] param;
		switch (model) {
		case ABBIRB140:
			param = new Kparameter[6];
			// DH parameters by this order: a d alfa tecta corrected (for 0
			// degrees)
			param[0] = new Kparameter(70, 352, Math.PI / 2, 0);
			param[1] = new Kparameter(360, 0, 0, Math.PI / 2);
			param[2] = new Kparameter(0, 0, Math.PI / 2, 0);
			param[3] = new Kparameter(0, 380, -Math.PI / 2, 0);
			param[4] = new Kparameter(0, 0, Math.PI / 2, 0);
			param[5] = new Kparameter(0, 65, 0, 0);
			return param;
		case VABBIRB140:
			return getDHParameters(RobotCatalog.ABBIRB140);
		case FANUCARC120:
			param = new Kparameter[6];
			// DH parameters by this order: a d alfa tecta corrected (for 0
			// degrees)
			param[0] = new Kparameter(0.150, 0,  -Math.PI/2,0);
			param[1] = new Kparameter(0.770, 0.0,  Math.PI, -Math.PI/2);
			param[2] = new Kparameter(0.100, 0, -Math.PI / 2, 0);
			param[3] = new Kparameter(0, -0.740, Math.PI / 2, Math.PI );
			param[4] = new Kparameter(0, 0, Math.PI / 2, Math.PI);
			param[5] = new Kparameter(0, 0.100, 0, 0);
			return param;
		case VFANUCARC120:
			return getDHParameters(RobotCatalog.FANUCARC120);
		}
		return null;
	}

	public static int[][] getWorkSpaceJoints(RobotCatalog model) {
		switch (model) {
		case ABBIRB140:
			int[][] joints = new int[2][6];
			joints[0][0] = -90;
			joints[1][0] = +90;
			joints[0][1] = -90;
			joints[1][1] = +110;
			joints[0][2] = -90;
			joints[1][2] = +90;
			joints[0][3] = -90;
			joints[1][3] = +90;
			joints[0][4] = -90;
			joints[1][4] = +90;
			joints[0][5] = -90;
			joints[1][5] = +90;
			return joints;
		case VABBIRB140:
			return getWorkSpaceJoints(RobotCatalog.ABBIRB140);
		}
		return null;
	}
}
